<!DOCTYPE html>
<html>
  
<!-- Mirrored from www.dba.cn/book/electron/ELECTRONJiaoCheng/ELECTRONZhuoMianHuanJingJiCheng.html by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 20 Mar 2022 10:23:56 GMT -->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Electron 桌面环境集成 - Electron中文手册</title>
    <link rel="stylesheet" type="text/css" href="../../skins/cms/css/min-easyui.css">
    <link rel="stylesheet" type="text/css" href="../../skins/cms/css/book.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../skins/cms/js/m-easyui.js"></script>
    <script type="text/javascript" src="../../skins/cms/js/prettify.js"></script>
  </head>
  <body class="easyui-layout" style="text-align:left">
    <div region="north" border="false" class="group wrap header" style="height:66px;font-size:100%">
      <div class="header">
        <div class="navigation-toggle" data-tools="navigation-toggle" data-target="#navbar-1">
          <span>Electron中文手册</span>
        </div>
        <div id="elogo" class="navbar navbar-left">
          <ul>
            <li>
              <h1><a href="../index.html">Electron中文手册</a></h1>
            </li>
          </ul>
        </div>
      <div style="clear:both"></div>
    </div>
   </div>
    <div region="west" split="true" data-options="collapsedSize:0,hideExpandTool:true" title="文档目录" style="width:20%;min-width:300px;padding:5px;display:none;">
        
      <ul class="easyui-tree"> 
        <li iconcls="icon-base"><span>Electron 教程</span><ul><li iconcls="icon-gears"><a href="ELECTRONJiaoChengJianJie.html">Electron 教程简介</a></li><li iconcls="icon-gears"><a  href="ELECTRONKuaiSuRuMen.html">Electron 快速入门</a></li><li iconcls="icon-gears"><a  href="ELECTRONZhuoMianHuanJingJiCheng.html">Electron 桌面环境集成</a></li><li iconcls="icon-gears"><a  href="ELECTRONZaiXianLiXianShiJianTanCe.html">Electron 在线/离线事件探测</a></li><li iconcls="icon-gears"><a  href="ELECTRONJinCheng.html">Electron 进程</a></li><li iconcls="icon-gears"><a  href="ELECTRONZhiChiDeCHROMEMingLingXingKaiGuan.html">Electron 支持的 Chrome 命令行开关</a></li><li iconcls="icon-gears"><a  href="ELECTRONHuanJingBianLiang.html">Electron 环境变量</a></li><li iconcls="icon-gears"><a  href="ELECTRONZhiChiDePingTai.html">Electron 支持的平台</a></li><li iconcls="icon-gears"><a  href="ELECTRONYingYongBuShu.html">Electron 应用部署</a></li><li iconcls="icon-gears"><a  href="ELECTRONXiangMACAPPSTOREYingYongTiJiaoXiangDao.html">Electron 向Mac App Store 应用提交向导</a></li><li iconcls="icon-gears"><a  href="ELECTRONYingYongDaBao.html">Electron 应用打包</a></li><li iconcls="icon-gears"><a  href="ELECTRONShiYongYuanShengMoKuai.html">Electron 使用原生模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONZhuJinChengDiaoShi.html">Electron 主进程调试</a></li><li iconcls="icon-gears"><a  href="ELECTRONShiYongSELENIUMHeWEBDRIVER.html">Electron 使用 Selenium 和 WebDriver</a></li><li iconcls="icon-gears"><a  href="ELECTRONDEVTOOLSKuoZhan.html">Electron DevTools扩展</a></li><li iconcls="icon-gears"><a  href="ELECTRONShiYongPEPPERFLASHChaJian.html">Electron 使用 Pepper Flash 插件</a></li><li iconcls="icon-gears"><a  href="ELECTRONShiYongWIDEVINECDMChaJian.html">Electron 使用 Widevine CDM 插件</a></li><li iconcls="icon-gears"><a  href="ELECTRONShuYuBiao.html">Electron 术语表</a></li><li iconcls="icon-gears"><a  href="ELECTRONLiPingRan.html">Electron 离屏渲染</a></li><li iconcls="icon-gears"><a  href="ELECTRONJiaoHuShiJieShiQiREPL.html">Electron 交互式解释器 (REPL)</a></li></ul></li><li iconcls="icon-base"><span>Electron API</span><ul><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONDOMFILEDuiXiang.html">Electron DOM File对象</a></li><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONDOMWEBVIEWBiaoQian.html">Electron DOM <webview> 标签</a></li><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONWINDOWOPENHanShu.html">Electron window.open 函数</a></li></ul></li><li iconcls="icon-base"><span>在主进程内可用的模块</span><ul><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONAPPMoKuai.html">Electron app 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONAUTOUPDATERMoKuai.html">Electron autoUpdater 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONBROWSERWINDOWMoKuai.html">Electron BrowserWindow 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONCONTENTTRACINGMoKuai.html">Electron contentTracing 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONDIALOGMoKuai.html">Electron dialog 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONGLOBAL-SHORTCUTMoKuai.html">Electron global-shortcut 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONIPCMAINMoKuai.html">Electron ipcMain 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONMENUMoKuai.html">Electron menu 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONMENUITEMMoKuai.html">Electron MenuItem 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONPOWERMONITORMoKuai.html">Electron powerMonitor 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONPOWERSAVEBLOCKERMoKuai.html">Electron powerSaveBlocker 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONPROTOCOLMoKuai.html">Electron protocol 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONSESSIONMoKuai.html">Electron session 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONWEBCONTENTSMoKuai.html">Electron webContents 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONTRAYMoKuai.html">Electron Tray 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONLOCALES.html">Electron Locales</a></li></ul></li><li iconcls="icon-base"><span>在渲染进程（网页）内可用的模块</span><ul><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONDESKTOPCAPTURERMoKuai.html">Electron desktopCapturer 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONIPCRENDERERMoKuai.html">Electron ipcRenderer 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONREMOTEMoKuai.html">Electron remote 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONWEBFRAMEMoKuai.html">Electron webFrame 模块</a></li></ul></li><li iconcls="icon-base"><span>两种进程都可用的模块</span><ul><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONCLIPBOARDMoKuai.html">Electron clipboard 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONCRASHREPORTERMoKuai.html">Electron crashReporter 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONNATIVEIMAGEMoKuai.html">Electron nativeImage 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONSCREENMoKuai.html">Electron screen 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONSHELLMoKuai.html">Electron shell 模块</a></li></ul></li><li iconcls="icon-base"><span>Electron 开发</span><ul><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONBianMaGuiFan.html">Electron 编码规范</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONYuanMaMuLuJieGou.html">Electron 源码目录结构</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONHeNWJSYuanMingNODE-WEBKITZaiJiShuShangDeChaYi.html">Electron 和 NW.js (原名 node-webkit) 在技术上的差异</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianXiTongGaiLan.html">Electron 构建系统概览</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianBuZhouOSX.html">Electron 构建步骤 (OS X)</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianBuZhouWINDOWS.html">Electron 构建步骤 (Windows)</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianBuZhouLINUX.html">Electron 构建步骤 (Linux)</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONZaiDiaoShiZhongShiYongSYMBOLSERVER.html">Electron 在调试中使用 Symbol Server</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONChangJianWenTi.html">Electron 常见问题</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONBanBenGuanLi.html">Electron 版本管理</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONWINDOWTiJiaoZhiNan.html">electron window 提交指南</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ZiDongHuaChiXuJiChengXiTongCICeShi.html">自动化持续集成系统（CI）测试</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONWenDangFengGeZhiNan.html">Electron 文档风格指南</a></li></ul></li>
      </ul>
    
    </div>
    <div region="center">
      <div id="tt" class="easyui-tabs" fit="true" border="false" plain="true">
        <div title="Electron 桌面环境集成 - Electron中文手册">  
            <div class="book-content">
              
      <div style="padding:8px;"> &gt; <a href="../index.html">Electron中文手册</a> &gt; Electron 桌面环境集成</div>
      <div class="content"><p class="comments-section">不同的操作系统在各自的桌面应用上提供了不同的特性。例如，在 windows 上应用曾经打开的文件会出现在任务栏的跳转列表，在 Mac 上，应用可以把自定义菜单放在鱼眼菜单上。</p>
<p class="comments-section">本章将会说明怎样使用 Electron APIs 把你的应用和桌面环境集成到一块。</p>
<h2 id="最近文档-windows--os-x">最近文档 (Windows &amp; OS X)</h2>
<p class="comments-section">Windows 和 OS X 提供获取最近文档列表的便捷方式，那就是打开跳转列表或者鱼眼菜单。</p>
<p class="comments-section">跳转列表：</p>
<p class="comments-section"><img src="687474703a2f2f692e6d73646e2e6d6963726f736f66742e636f6d2f64796e696d672f49433432303533382e706e67" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<p class="comments-section">鱼眼菜单：</p>
<p class="comments-section"><img src="2aa80758-6e97-11e4-8cfb-c1a414a10774.png" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<p class="comments-section">为了增加一个文件到最近文件列表，你可以使用 app.addRecentDocument API:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> app = <span class="hljs-built_in">require</span>(<span class="hljs-string">'app'</span>);
app.addRecentDocument(<span class="hljs-string">'/Users/USERNAME/Desktop/work.type'</span>);
</code></pre>
<p class="comments-section">或者你也可以使用 <a href="APPCLEARRECENTDOCUMENTS.html">app.clearRecentDocuments</a> API 来清空最近文件列表。</p>
<pre><code class="lang-javascript">app.clearRecentDocuments();
</code></pre>
<h2 id="windows-需注意">Windows 需注意</h2>
<p class="comments-section">为了这个特性在 Windows 上表现正常，你的应用需要被注册成为一种文件类型的句柄，否则，在你注册之前，文件不会出现在跳转列表。你可以在 Application Registration 里找到任何关于注册事宜的说明。</p>
<h2 id="os-x-需注意">OS X 需注意</h2>
<p class="comments-section">当一个文件被最近文件列表请求时，<code>app</code> 模块里的 <code>open-file</code> 事件将会被发出。</p>
<h2 id="自定义的鱼眼菜单os-x">自定义的鱼眼菜单(OS X)</h2>
<p class="comments-section">OS X 可以让开发者定制自己的菜单，通常会包含一些常用特性的快捷方式。</p>
<h3 id="菜单中的终端">菜单中的终端</h3>
<p><img src="6032658a-6e9c-11e4-9953-aa84006bdfff.png" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<p class="comments-section">使用 <code>app.dock.setMenu</code> API 来设置你的菜单，这仅在 OS X 上可行：</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> app = <span class="hljs-built_in">require</span>(<span class="hljs-string">'app'</span>);
<span class="hljs-keyword">var</span> Menu = <span class="hljs-built_in">require</span>(<span class="hljs-string">'menu'</span>);
<span class="hljs-keyword">var</span> dockMenu = Menu.buildFromTemplate([
  { label: <span class="hljs-string">'New Window'</span>, click: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'New Window'</span>); } },
  { label: <span class="hljs-string">'New Window with Settings'</span>, submenu: [
    { label: <span class="hljs-string">'Basic'</span> },
    { label: <span class="hljs-string">'Pro'</span>}
  ]},
  { label: <span class="hljs-string">'New Command...'</span>}
]);
app.dock.setMenu(dockMenu);
</code></pre>
<h2 id="用户任务windows">用户任务(Windows)</h2>
<p class="comments-section">在 Windows，你可以特别定义跳转列表的 <code>Tasks</code> 目录的行为，引用 MSDN 的文档：</p>
<blockquote>
<p class="comments-section">Applications define tasks based on both the program's features and the key things a user is expected to do with them. Tasks should be context-free, in that the application does not need to be running for them to work. They should also be the statistically most common actions that a normal user would perform in an application, such as compose an email message or open the calendar in a mail program, create a new document in a word processor, launch an application in a certain mode, or launch one of its subcommands. An application should not clutter the menu with advanced features that standard users won't need or one-time actions such as registration. Do not use tasks for promotional items such as upgrades or special offers.</p>
<p class="comments-section">It is strongly recommended that the task list be static. It should remain the same regardless of the state or status of the application. While it is possible to vary the list dynamically, you should consider that this could confuse the user who does not expect that portion of the destination list to change.</p>
</blockquote>
<h3 id="ie-的任务">IE 的任务</h3>
<p class="comments-section"><img src="687474703a2f2f692e6d73646e2e6d6963726f736f66742e636f6d2f64796e696d672f49433432303533392e706e67" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<p class="comments-section">不同于 OS X 的鱼眼菜单，Windows 上的用户任务表现得更像一个快捷方式，比如当用户点击一个任务，一个程序将会被传入特定的参数并且运行。</p>
<p class="comments-section">你可以使用 <a href="APPSETUSERTASKS.html">app.setUserTasks</a> API 来设置你的应用中的用户任务：</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> app = <span class="hljs-built_in">require</span>(<span class="hljs-string">'app'</span>);
app.setUserTasks([
  {
    program: process.execPath,
    <span class="hljs-built_in">arguments</span>: <span class="hljs-string">'--new-window'</span>,
    iconPath: process.execPath,
    iconIndex: <span class="hljs-number">0</span>,
    title: <span class="hljs-string">'New Window'</span>,
    description: <span class="hljs-string">'Create a new window'</span>
  }
]);
</code></pre>
<p class="comments-section">调用 <code>app.setUserTasks</code> 并传入空数组就可以清除你的任务列表：</p>
<pre><code class="lang-javascript">app.setUserTasks([]);
</code></pre>
<p class="comments-section">当你的应用关闭时，用户任务会仍然会出现，在你的应用被卸载前，任务指定的图标和程序的路径必须是存在的。</p>
<h3 id="缩略图工具栏">缩略图工具栏</h3>
<p class="comments-section">在 Windows，你可以在任务栏上添加一个按钮来当作应用的缩略图工具栏。它将提供用户一种用户访问常用窗口的方式，并且不需要恢复或者激活窗口。</p>
<p class="comments-section">在 MSDN，它被如是说：</p>
<blockquote>
<p class="comments-section">This toolbar is simply the familiar standard toolbar common control. It has a maximum of seven buttons. Each button's ID, image, tooltip, and state are defined in a structure, which is then passed to the taskbar. The application can show, enable, disable, or hide buttons from the thumbnail toolbar as required by its current state.</p>
<p class="comments-section">For example, Windows Media Player might offer standard media transport controls such as play, pause, mute, and stop.</p>
</blockquote>
<h3 id="windows-media-player-的缩略图工具栏">Windows Media Player 的缩略图工具栏</h3>
<p class="comments-section"><img src="68747470733a2f2f692d6d73646e2e7365632e732d6d7366742e636f6d2f64796e696d672f49433432303534302e706e67" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<p class="comments-section">你可以使用 <a href="BROWSERWINDOWSETTHUMBARBUTTONS.html">BrowserWindow.setThumbarButtons</a> 来设置你的应用的缩略图工具栏。</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> BrowserWindow = <span class="hljs-built_in">require</span>(<span class="hljs-string">'browser-window'</span>);
<span class="hljs-keyword">var</span> path = <span class="hljs-built_in">require</span>(<span class="hljs-string">'path'</span>);
<span class="hljs-keyword">var</span> win = <span class="hljs-keyword">new</span> BrowserWindow({
  width: <span class="hljs-number">800</span>,
  height: <span class="hljs-number">600</span>
});
win.setThumbarButtons([
  {
    tooltip: <span class="hljs-string">"button1"</span>,
    icon: path.join(__dirname, <span class="hljs-string">'button1.png'</span>),
    click: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"button2 clicked"</span>); }
  },
  {
    tooltip: <span class="hljs-string">"button2"</span>,
    icon: path.join(__dirname, <span class="hljs-string">'button2.png'</span>),
    flags:[<span class="hljs-string">'enabled'</span>, <span class="hljs-string">'dismissonclick'</span>],
    click: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"button2 clicked."</span>); }
  }
]);
</code></pre>
<p class="comments-section">调用 <code>BrowserWindow.setThumbarButtons</code> 并传入空数组即可清空缩略图工具栏：</p>
<pre><code class="lang-javascript">win.setThumbarButtons([]);
</code></pre>
<h2 id="unity-launcher-快捷方式linux">Unity launcher 快捷方式(Linux)</h2>
<p class="comments-section">在 Unity,你可以通过改变 <code>.desktop</code> 文件来增加自定义运行器的快捷方式，详情看 Adding shortcuts to a launcher。</p>
<h3 id="audacious-运行器的快捷方式：">Audacious 运行器的快捷方式：</h3>
<p><img src="68747470733a2f2f68656c702e7562756e74752e636f6d2f636f6d6d756e6974792f556e6974794c61756e6368657273416e644465736b746f7046696c65733f616374696f6e3d4174" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<h2 id="任务栏的进度条windows--unity">任务栏的进度条(Windows &amp; Unity)</h2>
<p class="comments-section">在 Windows，进度条可以出现在一个任务栏按钮之上。这可以提供进度信息给用户而不需要用户切换应用窗口。</p>
<p class="comments-section">Unity DE 也具有同样的特性，在运行器上显示进度条。</p>
<h3 id="在任务栏上的进度条：">在任务栏上的进度条：</h3>
<p><img src="16691fda-6f0e-11e4-9676-49b6418f1264.png" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<h3 id="在-unity-运行器上的进度条">在 Unity 运行器上的进度条</h3>
<p><img src="4a0a589e-6f0f-11e4-803f-91594716a546.png" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<p class="comments-section">给一个窗口设置进度条，你可以调用 <a href="BROWSERWINDOWSETPROGRESSBAR.html">BrowserWindow.setProgressBar</a> API：</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> <span class="hljs-built_in">window</span> = <span class="hljs-keyword">new</span> BrowserWindow({...});
<span class="hljs-built_in">window</span>.setProgressBar(<span class="hljs-number">0.5</span>);
</code></pre>
<p class="comments-section">在 OS X，一个窗口可以设置它展示的文件，文件的图标可以出现在标题栏，当用户 Command-Click 或者 Control-Click 标题栏，文件路径弹窗将会出现。</p>
<h3 id="展示文件弹窗菜单：">展示文件弹窗菜单：</h3>
<p><img src="670a949a-6f14-11e4-987a-9aaa04b23c1d.png" alt="Electron 桌面环境集成" style="max-width:80%;" /></p>
<p class="comments-section">你可以调用 <a href="BROWSERWINDOWSETREPRESENTEDFILENAME.html">BrowserWindow.setRepresentedFilename</a> 和 <a href="BROWSERWINDOWSETDOCUMENTEDITED.html">BrowserWindow.setDocumentEdited</a> APIs：</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> <span class="hljs-built_in">window</span> = <span class="hljs-keyword">new</span> BrowserWindow({...});
<span class="hljs-built_in">window</span>.setRepresentedFilename(<span class="hljs-string">'/etc/passwd'</span>);
<span class="hljs-built_in">window</span>.setDocumentEdited(<span class="hljs-literal">true</span>);
</code></pre></div>
      <div class="prev-next" style="padding:8px;">上一篇：<a class="prev" href="ELECTRONKuaiSuRuMen.html">Electron 快速入门</a><br>下一篇：<a class="prev" href="ELECTRONZaiXianLiXianShiJianTanCe.html">Electron 在线/离线事件探测</a><br></div>
    
            </div>
        </div> 
      </div>
    </div>
  </body>

<!-- Mirrored from www.dba.cn/book/electron/ELECTRONJiaoCheng/ELECTRONZhuoMianHuanJingJiCheng.html by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 20 Mar 2022 10:24:03 GMT -->
</html>